module ExpensesHelper

  def get_category_total(category)
    total = 0
    category.expenses.each do |expense|
      total += expense.amount
    end
    return total
  end

  def get_date_bins_for_expenses(expenses)
    bins = Hash.new()
    expenses.each do |expense|
      date = expense.created_at.strftime("%b %d, %Y")
      if bins[date] == nil
        bins[date] = []
      end
      bins[date] << expense
    end
    return bins
  end

end
